package jumpingnotes.dao.hibernate;

import jumpingnotes.dao.SyncDao;
import jumpingnotes.model.entity.Sync;

import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.orm.hibernate3.HibernateCallback;

public class SyncHibernateDao extends GenericHibernateDao<Sync> implements SyncDao
{
	public SyncHibernateDao()
	{
		super(Sync.class);
	}

	@SuppressWarnings("unchecked")
	public Sync findSyncByUuid(final String uuid)
	{
		return (Sync) getHibernateTemplate().execute(new HibernateCallback()
		{
			public Object doInHibernate(Session session) throws HibernateException
			{
				Query query = session.createQuery("select distinct s from Sync s where s.uuid=:uuid");
				query.setString("uuid", uuid);
				return query.uniqueResult();
			}
		});
	}
}
